-- CALC_AVALON_CANNON_ATTACK_POS

-- 计算阿瓦隆巨炮的攻击范围
return function(avalonCannon, attackRange)
    local posList = {};

    -- 获取自己的位置
    local classId = avalonCannon.classId;
    local cannonPos;

    if DungeonBossM.isInBossLayer() then
        cannonPos = AvalonCannonM.query(classId, "boss_layer_pos");
    else
        cannonPos = AvalonCannonM.query(classId, "normal_pos");
    end

    -- 遍历格子，找到攻击范围之内的格子位置
    for i = 1, DUNGEON_HEIGHT do
        for j = 1, DUNGEON_WIDTH do
            local range = math.abs(cannonPos[1] - i) + math.abs(cannonPos[2] - j);
            if range - attackRange <= 0 and range ~= 0 then
                table.insert(posList, (i - 1) * DUNGEON_WIDTH + j);
            end
        end
    end

    return posList;
end
